const apiContext = import.meta.glob('./api/*.js',{ eager: true });
const apis = {};
// for (const key in apiContext) {
//   const apiModule = apiContext[key];
//   for (const apiName in apiModule) {
//     if (!apis[apiName]) {
//       apis[apiName] = {};
//     }
//     Object.assign(apis[apiName], apiModule[apiName]);
//   }
// }

export default function install(app) {
	console.log(apiContext,'nnnnnn')
	for (const key in apiContext) {
		const apiModule = apiContext[key];
		for (const apiName in apiModule) {
		  if (!apis[apiName]) {
			apis[apiName] = {};
		  }
		  Object.assign(apis[apiName], apiModule[apiName]);
		  app.config.globalProperties['$'+apiName] = apiModule[apiName];
		}
	  }


//   for (const key of Object.entries(apiContext)) {
//     const name = key.slice(key.lastIndexOf('/') + 1, key.lastIndexOf('.'));
// 	console.log(name,key,'ssssssssssssss')
	// Object.assign(apis[name], value);
	  // app.config.globalProperties['$'+name] = value;
	  // console.log(apis,'mmmmmmmm')
    // app.component(name.charAt(0).toUpperCase() + componentName.slice(1), defineAsyncComponent(value));
//   }
}
// export default function mountGlobalApis(app) {
// 	console.log(apis,'mmmmmmmm')
//   app.config.globalProperties.$apis = apis;
// }